<?php
	require_once("../../db/dbclass.php");
	require_once("../../model/userinfo.php");
	require_once("../../utils/common.php");
	$myDb=&DbController::getInstance();
	$tweets_id=$_POST['tweets_id'];
	$tweets_status=$_POST['tweets_status'];
	if($tweets_status==2){
		$param="select * from yj_tweets where tweets_id=$tweets_id";
		$result=$myDb->exec_query($param);
		if($result==TRUE){
			$user_id="";
			while($row = mysqli_fetch_array($result,MYSQL_ASSOC)){
				$user_id=$row['user_id'];
			}
			$param="select * from yj_sensitivity_user where user_id='".$user_id."' and tweets_id='".$tweets_id."'";
			$result=$myDb->exec_query($param);
			if($result==TRUE){
				if(mysqli_fetch_array($result,MYSQL_ASSOC)==0){
					$param="INSERT INTO yj_sensitivity_user(user_id,tweets_id) VALUES ($user_id,$tweets_id)";
					$result=$myDb->exec_query($param);
					if($result==TRUE){
						// 插入成功
					}
					else{
						echo "{'result':'failure'}";
						return;
					}
				}
			}
		}
		else{
			echo "{'result':'failure'}";
			return;
		}
		$tweets_content=$_POST['tweets_content'];
		$param="UPDATE yj_tweets SET tweets_content='".$tweets_content."' WHERE tweets_id='".$tweets_id."'";
		$result=$myDb->exec_query($param);
		if($result==TRUE){
			// 修改成功
		}
		else{
			echo "{'result':'failure'}";
			return;
		}
	}
	$param="DELETE FROM yj_sensitivity_record WHERE tweets_id='".$tweets_id."'";
	$result=$myDb->exec_query($param);
	if($result==TRUE){
		echo "{'result':'success'}";
		return;
	}
	echo "{'result':'failure'}";
?>